void
gtk_css_style_snapshot_icon_texture (GtkCssStyle *style,
GtkSnapshot *snapshot,
- GskTexture *texture)
+ GskTexture *texture,
+ double texture_scale)
{
const GtkCssValue *shadows, *transform;
- graphene_matrix_t transform_matrix, m1, m2, m3, saved_matrix;
+ graphene_matrix_t transform_matrix, translate, matrix, saved_matrix;
graphene_rect_t bounds;
GskRenderNode *node;
- int width, height;
+ double width, height;
static gboolean shadow_warning;
g_return_if_fail (GTK_IS_CSS_STYLE (style));
g_return_if_fail (snapshot != NULL);
g_return_if_fail (GSK_IS_TEXTURE (texture));
+ g_return_if_fail (texture_scale > 0);
shadows = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ICON_SHADOW);
transform = gtk_css_style_get_value (style, GTK_CSS_PROPERTY_ICON_TRANSFORM);
- width = gsk_texture_get_width (texture);
- height = gsk_texture_get_height (texture);
+ width = gsk_texture_get_width (texture) / texture_scale;
+ height = gsk_texture_get_height (texture) / texture_scale;
if (!gtk_css_transform_value_get_matrix (transform, &transform_matrix))
return;
graphene_matrix_init_from_matrix (&saved_matrix, gtk_snapshot_get_transform (snapshot));
/* XXX: Implement -gtk-icon-transform-origin instead of hardcoding "50% 50%" here */
- graphene_matrix_init_translate (&m1, &GRAPHENE_POINT3D_INIT(width / 2.0, height / 2.0, 0));
- graphene_matrix_multiply (&transform_matrix, &m1, &m3);
- graphene_matrix_init_translate (&m2, &GRAPHENE_POINT3D_INIT(- width / 2.0, - height / 2.0, 0));
- graphene_matrix_multiply (&m2, &m3, &m1);
- gtk_snapshot_transform (snapshot, &m1);
+ graphene_matrix_init_translate (&translate, &GRAPHENE_POINT3D_INIT(width / 2.0, height / 2.0, 0));
+ graphene_matrix_multiply (&transform_matrix, &translate, &matrix);
+ graphene_matrix_translate (&matrix, &GRAPHENE_POINT3D_INIT(- width / 2.0, - height / 2.0, 0));
+ graphene_matrix_scale (&matrix, 1.0 / texture_scale, 1.0 / texture_scale, 1);
+ gtk_snapshot_transform (snapshot, &matrix);
- graphene_rect_init (&bounds, 0, 0, width, height);
+ graphene_rect_init (&bounds, 0, 0, gsk_texture_get_width (texture), gsk_texture_get_height (texture));
node = gtk_snapshot_append (snapshot, &bounds, "Icon");
if (!_gtk_css_shadows_value_is_none (shadows) && !shadow_warning)